package com.tencent.iov.cowin.befsale.clue.repository.clue.impl;

import com.github.pagehelper.Page;
import com.tencent.iov.cowin.befsale.clue.dao.clue.DistributeRuleDao;
import com.tencent.iov.cowin.befsale.clue.domain.clue.po.DistributeRule;
import com.tencent.iov.cowin.befsale.clue.repository.clue.DistributeRuleManager;
import com.tencent.iov.cowin.befsale.clue.value.contants.ServiceConstant;
import com.software.boot.dao.annotation.TargetDataSource;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Describe: 下发规则表_Manager实现层
 * @author: xuxiao.liu
 * @created: 2022-01-24 17:59:59
 * @version: 1.0
 */
@Service
public class DistributeRuleManagerImpl implements DistributeRuleManager {
	
	@Autowired
	private DistributeRuleDao distributeRuleDao;

	/**
	 * 通过ID获取详细信息
	 *
	 * @param: id
	 * @return: DistributeRule对象
	 */
	@Override
	@TargetDataSource(ServiceConstant.QW_SALE_READ)
	public DistributeRule getDetailById(Long id){
		return distributeRuleDao.getDetailById(id);
	}

	/**
	 * 单条数据插入DistributeRule
	 * @param request
	 * @return 插入的条数
	 */
	@Override
	@TargetDataSource(ServiceConstant.QW_SALE_WRITE)
	public int insert(DistributeRule request){
		return distributeRuleDao.insert(request);
    }

	/**
	 * 批量插入DistributeRule
	 * @param requests
	 * @return 批量插入的条数
	 */
	@Override
	@TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int insertBatch(List<DistributeRule> requests){
		return distributeRuleDao.insertBatch(requests);
    }

	/**
	 * 单条DistributeRule更新
	 * @param request
	 * @return 更新的条数
	 */
	@Override
	@TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int update(DistributeRule request){
		return distributeRuleDao.update(request);
    }

	/**
	 * 单条DistributeRule删除
	 * @param id
	 * @return 删除的条数
	 */
	@Override
	@TargetDataSource(ServiceConstant.QW_SALE_WRITE)
	public int delete(Integer id) {
		return distributeRuleDao.delete(id);
	}

	/**
	 * 根据条件查询对象list列表
	 * @param request
	 * @return 查询结果
	 */
	@Override
	@TargetDataSource(ServiceConstant.QW_SALE_READ)
	public List<DistributeRule> getListByParam(DistributeRule request){
		return distributeRuleDao.getListByParam(request);
	}

	/**
	 * 根据条件查询对象page记录
	 * @param request
	 * @param rowBounds
	 * @return 分页对象
	 */
	@Override
	@TargetDataSource(ServiceConstant.QW_SALE_READ)
	public Page<DistributeRule> getPageByParam(DistributeRule request, RowBounds rowBounds){
		return distributeRuleDao.getPageByParam(request, rowBounds);
	}

	/**
	 * 根据条件查询单个对象
	 * @param request
	 * @return
	 */
	@Override
	@TargetDataSource(ServiceConstant.QW_SALE_READ)
	public DistributeRule getOneByParam(DistributeRule request) {
			return distributeRuleDao.getOneByParam(request);
	}
}
